package com.power.sifa.std.dao;

import com.power.sifa.std.model.Std_admunit;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 行政管理单位 持久层(hibernate)
 */

public interface Std_admunitDao extends JpaRepository<Std_admunit, Serializable>, JpaSpecificationExecutor<Std_admunit>, Repository<Std_admunit, Serializable>, Std_admunitDaoCustom<Std_admunit, Serializable> {

    @Modifying
    @Transactional
    @Query("delete  from Std_admunit s where  s.id in (:ids) ")
    void removeByIds(@Param("ids") List<Integer> ids);

    @Query(" from Std_admunit s where  s.adid in (:adids) ")
    List<Std_admunit> findByAdids(@Param("adids") List<String> adids);

    @Query(" from Std_admunit s where  s.id in (:ids) ")
    List<Std_admunit> findByIds(@Param("ids") List<String> ids);

    @Query(" from Std_admunit s ")
    List<Std_admunit> list();

    @Query("select max(s.sortnum)  from Std_admunit s ")
    Integer queryMaxSort();

}
